fn main() {
    println!("{}", Solution::is_palindrome(123));
    println!("{}", Solution::is_palindrome(12321));
}

struct Solution;

impl Solution {
    pub fn is_palindrome(x: i32) -> bool {
        if x < 0 {
            return false;
        } else if x < 10 {
            return true;
        } else {
            let mut num = x;
            let mut tmp;
            let mut count = 0;
            let mut arr = [0; 10];
            // 2147483648
            while num != 0 {
                tmp = num % 10;
                num = num / 10;
                arr[count] = tmp;
                count = count + 1;
            }
            for i in 0..count / 2 {
                if arr[i] != arr[count - i - 1] {
                    return false;
                }
            }
            return true;
        }
    }
}
